package main

import (
	api "data/api"
	router "data/router"
	"fmt"
	"io"
	"os"

	"github.com/gin-gonic/gin"
)

// main 入口
func main() {
	// 创建记录日志的文件
	f, _ := os.Create("web.log")
	gin.DefaultWriter = io.MultiWriter(f)

	// 创建路由
	r := gin.Default()

	// 跨域
	r.Use(api.Cors())

	// 记录日志
	gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {}

	r.GET("/main", router.Main)
	r.POST("/upload", router.Upload)

	fmt.Println("成功运行")
	r.Run(":6061")
}
